import java.util.*;

/*
 * 1 = [0,10,9]
 * 10 = [0,10]
 *
 *
 * */

public class 第八题 {
    public static int id;
    public static int ts;
    public static Set<Integer> ansSet = new HashSet<>();

    public static void main(String[] args) {
        HashMap<Integer, ArrayList<Integer>> hm = new HashMap<>();
        Scanner sc = new Scanner(System.in);
        int[] data = new int[3];

        for (int i = 0; i < data.length; i++) {
            data[i] = sc.nextInt();
        }

        for (int i = 0; i < data[0]; i++) {
            ts = sc.nextInt();
            id = sc.nextInt();

            if (!hm.containsKey(id)) { // 事先没有这个id
                ArrayList<Integer> list = new ArrayList<>();
                list.add(ts);
                hm.put(id, list);
            } else { // 事后有了这个id
                ArrayList<Integer> arrayList = hm.get(id);
                arrayList.add(ts);
                hm.put(id, arrayList);
            }
        }
        System.out.println(hm);

        Set<Integer> integers = hm.keySet();
        for (Integer dataKey : integers) {
            ArrayList<Integer> arrayList = hm.get(dataKey);
            if (arrayList.size() >= data[2]) {
                Collections.sort(arrayList);
                for (int index1 = 0; index1 < arrayList.size(); index1++) {
                    int count = 1;
                    for (int i = index1+1; i < arrayList.size(); i++) {
                        if(arrayList.get(i) - arrayList.get(index1) < data[1]){
                            count += 1;
                        }
                    }
                    if(count >= data[2]){
                        ansSet.add(dataKey);
                        break;
                    }
                }
            }
        }
        System.out.println(ansSet);
    }
}
